{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "92177e11",
   "metadata": {},
   "source": [
    "# Lab4Processing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "9b834bb9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        gaze_timestamp  world_index  confidence  norm_pos_x  norm_pos_y  \\\n",
      "0         88150.776780            0    0.828006    0.531433    0.397509   \n",
      "1         88150.776787            0    0.459705    0.337051    0.186147   \n",
      "2         88150.779709            0    0.888789    0.543140    0.410668   \n",
      "3         88150.779759            0    0.550258    0.337923    0.173301   \n",
      "4         88150.787485            1    0.502595    0.340109    0.142989   \n",
      "...                ...          ...         ...         ...         ...   \n",
      "125259    88443.695600         8788    0.995336    0.407831    0.413470   \n",
      "125260    88443.697570         8788    0.948733    0.407552    0.414731   \n",
      "125261    88443.701580         8788    0.945284    0.407467    0.414705   \n",
      "125262    88443.703608         8788    0.945284    0.407160    0.415340   \n",
      "125263    88443.705574         8788    0.945284    0.407637    0.413674   \n",
      "\n",
      "                                 base_data  gaze_point_3d_x  gaze_point_3d_y  \\\n",
      "0                            88150.77678-0        28.369753        52.033135   \n",
      "1                           88150.776787-1      -142.869866       154.788121   \n",
      "2                           88150.779709-0        38.942051        45.359863   \n",
      "3                           88150.779759-1      -141.879169       160.867779   \n",
      "4                           88150.787485-1      -139.404860       175.088321   \n",
      "...                                    ...              ...              ...   \n",
      "125259        88443.69561-0 88443.695591-1       327.648915      -173.027524   \n",
      "125260   88443.69561-0 88443.69953099999-1       311.054477      -161.381388   \n",
      "125261  88443.703629-0 88443.69953099999-1       313.566509      -162.585330   \n",
      "125262       88443.703629-0 88443.703587-1       297.019831      -152.352987   \n",
      "125263  88443.703629-0 88443.70751899999-1       323.629974      -170.142461   \n",
      "\n",
      "        gaze_point_3d_z  eye_center0_3d_x  ...  eye_center0_3d_z  \\\n",
      "0            705.121116         20.000000  ...        -20.000000   \n",
      "1            684.981621        -39.934928  ...        -20.075283   \n",
      "2            705.232112         20.000000  ...        -20.000000   \n",
      "3            683.893108        -39.934928  ...        -20.075283   \n",
      "4            681.151453        -39.934928  ...        -20.075283   \n",
      "...                 ...               ...  ...               ...   \n",
      "125259     -2777.243340         19.888755  ...        -20.707271   \n",
      "125260     -2628.637408         19.888755  ...        -20.707271   \n",
      "125261     -2647.420719         19.888755  ...        -20.707271   \n",
      "125262     -2499.428189         19.888755  ...        -20.707271   \n",
      "125263     -2737.404466         19.888755  ...        -20.707271   \n",
      "\n",
      "        gaze_normal0_x  gaze_normal0_y  gaze_normal0_z  eye_center1_3d_x  \\\n",
      "0             0.011527        0.051002        0.998632               NaN   \n",
      "1            -0.141761        0.192518        0.971000               NaN   \n",
      "2             0.026087        0.041811        0.998785               NaN   \n",
      "3            -0.140397        0.200891        0.969501               NaN   \n",
      "4            -0.136989        0.220475        0.965725               NaN   \n",
      "...                ...             ...             ...               ...   \n",
      "125259       -0.110854        0.041843        0.992955        -37.372594   \n",
      "125260       -0.110854        0.041843        0.992955        -37.372594   \n",
      "125261       -0.111009        0.041794        0.992940        -37.372594   \n",
      "125262       -0.111009        0.041794        0.992940        -37.372594   \n",
      "125263       -0.111009        0.041794        0.992940        -37.372594   \n",
      "\n",
      "        eye_center1_3d_y  eye_center1_3d_z  gaze_normal1_x  gaze_normal1_y  \\\n",
      "0                    NaN               NaN             NaN             NaN   \n",
      "1                    NaN               NaN             NaN             NaN   \n",
      "2                    NaN               NaN             NaN             NaN   \n",
      "3                    NaN               NaN             NaN             NaN   \n",
      "4                    NaN               NaN             NaN             NaN   \n",
      "...                  ...               ...             ...             ...   \n",
      "125259         14.763454        -23.294339       -0.130868        0.093021   \n",
      "125260         14.763454        -23.294339       -0.132037        0.091860   \n",
      "125261         14.763454        -23.294339       -0.132037        0.091860   \n",
      "125262         14.763454        -23.294339       -0.133311        0.091656   \n",
      "125263         14.763454        -23.294339       -0.131320        0.092941   \n",
      "\n",
      "        gaze_normal1_z  \n",
      "0                  NaN  \n",
      "1                  NaN  \n",
      "2                  NaN  \n",
      "3                  NaN  \n",
      "4                  NaN  \n",
      "...                ...  \n",
      "125259        0.987026  \n",
      "125260        0.986979  \n",
      "125261        0.986979  \n",
      "125262        0.986827  \n",
      "125263        0.986974  \n",
      "\n",
      "[125264 rows x 21 columns]\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "data = pd.read_csv('gaze.csv')\n",
    "print(data)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2073cec",
   "metadata": {},
   "source": [
    "## (1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "40465e24",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "剩余数据条数: 87442\n"
     ]
    }
   ],
   "source": [
    "data = data[data['confidence'] >= 0.9]\n",
    "print(f\"剩余数据条数: {len(data)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a5351fc",
   "metadata": {},
   "source": [
    "## (2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "cf04c8fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "剩余数据条数: 120036\n"
     ]
    }
   ],
   "source": [
    "df = pd.read_csv('gaze.csv')\n",
    "\n",
    "mean_norm_pos_x = df['norm_pos_x'].mean()\n",
    "std_norm_pos_x = df['norm_pos_x'].std()\n",
    "mean_norm_pos_y = df['norm_pos_y'].mean()\n",
    "std_norm_pos_y = df['norm_pos_y'].std()\n",
    "\n",
    "df = df[\n",
    "    (df['norm_pos_x'] <= mean_norm_pos_x + 3 * std_norm_pos_x) &\n",
    "    (df['norm_pos_x'] >= mean_norm_pos_x - 3 * std_norm_pos_x) &\n",
    "    (df['norm_pos_y'] <= mean_norm_pos_y + 3 * std_norm_pos_y) &\n",
    "    (df['norm_pos_y'] >= mean_norm_pos_y - 3 * std_norm_pos_y)\n",
    "]\n",
    "\n",
    "num_data_after_filtering = len(df)\n",
    "print(\"剩余数据条数:\", num_data_after_filtering)\n",
    "\n",
    "# data = pd.read_csv('gaze.csv')\n",
    "# for column in ['norm_pos_x', 'norm_pos_y']:\n",
    "#     mean = data[column].mean()\n",
    "#     sigma = data[column].std()\n",
    "#     data = data[(data[column] >= mean - 3 * sigma) & (data[column] <= mean + 3 * sigma)]\n",
    "# print(f\"剩余数据条数: {len(data)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "102cad8c",
   "metadata": {},
   "source": [
    "## (3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "690d098a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                     gaze_timestamp  world_index  confidence  norm_pos_x  \\\n",
      "0   1970-01-02T00:29:10.776780+0000            0    0.828006    0.531433   \n",
      "1   1970-01-02T00:29:10.776787+0000            0    0.459705    0.337051   \n",
      "2   1970-01-02T00:29:10.779709+0000            0    0.888789    0.543140   \n",
      "3   1970-01-02T00:29:10.779759+0000            0    0.550258    0.337923   \n",
      "4   1970-01-02T00:29:10.787485+0000            1    0.502595    0.340109   \n",
      "5   1970-01-02T00:29:10.787579+0000            1    0.625134    0.484139   \n",
      "6   1970-01-02T00:29:10.789480+0000            1    0.625134    0.489687   \n",
      "7   1970-01-02T00:29:10.793583+0000            1    0.625134    0.495993   \n",
      "8   1970-01-02T00:29:10.795682+0000            1    0.706355    0.493975   \n",
      "9   1970-01-02T00:29:10.798406+0000            1    0.708476    0.494116   \n",
      "10  1970-01-02T00:29:10.801140+0000            1    0.708476    0.495145   \n",
      "11  1970-01-02T00:29:10.802973+0000            1    0.839662    0.495216   \n",
      "12  1970-01-02T00:29:10.804630+0000            1    0.791032    0.494728   \n",
      "13  1970-01-02T00:29:10.807269+0000            1    0.856341    0.494777   \n",
      "14  1970-01-02T00:29:10.809748+0000            1    0.856341    0.494888   \n",
      "15  1970-01-02T00:29:10.812872+0000            2    0.856341    0.494809   \n",
      "16  1970-01-02T00:29:10.814136+0000            2    0.716398    0.494057   \n",
      "17  1970-01-02T00:29:10.815997+0000            2    0.836166    0.493629   \n",
      "18  1970-01-02T00:29:10.818051+0000            2    0.836166    0.493772   \n",
      "19  1970-01-02T00:29:10.821819+0000            2    0.861113    0.493453   \n",
      "\n",
      "    norm_pos_y                                base_data  gaze_point_3d_x  \\\n",
      "0     0.397509                            88150.77678-0        28.369753   \n",
      "1     0.186147                           88150.776787-1      -142.869866   \n",
      "2     0.410668                           88150.779709-0        38.942051   \n",
      "3     0.173301                           88150.779759-1      -141.879169   \n",
      "4     0.142989                           88150.787485-1      -139.404860   \n",
      "5     0.385491  88150.78368299999-0 88150.79147699999-1         6.784204   \n",
      "6     0.392849       88150.787484-0 88150.79147699999-1         4.180437   \n",
      "7     0.399021        88150.79569-0 88150.79147699999-1         1.533100   \n",
      "8     0.408429             88150.79569-0 88150.795675-1         2.226758   \n",
      "9     0.407109             88150.79569-0 88150.801123-1         2.179629   \n",
      "10    0.408338            88150.801157-0 88150.801123-1         1.782444   \n",
      "11    0.403442             88150.801157-0 88150.80479-1         1.757366   \n",
      "12    0.405146             88150.804471-0 88150.80479-1         1.944664   \n",
      "13    0.404969             88150.809749-0 88150.80479-1         1.925755   \n",
      "14    0.402216            88150.809749-0 88150.809748-1         1.887678   \n",
      "15    0.402125            88150.809749-0 88150.815997-1         1.914321   \n",
      "16    0.401233       88150.81227499999-0 88150.815997-1         2.205674   \n",
      "17    0.400583       88150.81599799999-0 88150.815997-1         2.373377   \n",
      "18    0.400270       88150.81599799999-0 88150.820104-1         2.325815   \n",
      "19    0.399839            88150.823534-0 88150.820104-1         2.451823   \n",
      "\n",
      "    gaze_point_3d_y  gaze_point_3d_z  eye_center0_3d_x  ...  eye_center0_3d_z  \\\n",
      "0         52.033135       705.121116         20.000000  ...        -20.000000   \n",
      "1        154.788121       684.981621        -39.934928  ...        -20.075283   \n",
      "2         45.359863       705.232112         20.000000  ...        -20.000000   \n",
      "3        160.867779       683.893108        -39.934928  ...        -20.075283   \n",
      "4        175.088321       681.151453        -39.934928  ...        -20.075283   \n",
      "5        -27.550520      -334.161525         20.000000  ...        -20.000000   \n",
      "6        -24.431546      -316.680240         20.000000  ...        -20.000000   \n",
      "7        -21.730862      -298.890441         20.000000  ...        -20.000000   \n",
      "8        -19.036160      -288.727225         20.000000  ...        -20.000000   \n",
      "9        -19.354530      -289.386597         20.000000  ...        -20.000000   \n",
      "10       -18.930993      -286.849309         20.000000  ...        -20.000000   \n",
      "11       -19.951730      -286.984799         20.000000  ...        -20.000000   \n",
      "12       -19.682136      -288.194181         20.000000  ...        -20.000000   \n",
      "13       -19.710658      -288.072115         20.000000  ...        -20.000000   \n",
      "14       -20.312303      -288.507800         20.000000  ...        -20.000000   \n",
      "15       -20.302480      -288.102445         20.000000  ...        -20.000000   \n",
      "16       -20.620175      -289.966778         20.000000  ...        -20.000000   \n",
      "17       -20.832665      -291.039161         20.000000  ...        -20.000000   \n",
      "18       -20.950335      -291.765325         20.000000  ...        -20.000000   \n",
      "19       -21.099370      -292.574406         20.000000  ...        -20.000000   \n",
      "\n",
      "    gaze_normal0_x  gaze_normal0_y  gaze_normal0_z  eye_center1_3d_x  \\\n",
      "0         0.011527        0.051002        0.998632               NaN   \n",
      "1        -0.141761        0.192518        0.971000               NaN   \n",
      "2         0.026087        0.041811        0.998785               NaN   \n",
      "3        -0.140397        0.200891        0.969501               NaN   \n",
      "4        -0.136989        0.220475        0.965725               NaN   \n",
      "5         0.041430        0.034837        0.998534        -39.934928   \n",
      "6         0.052495        0.029825        0.998176        -39.934928   \n",
      "7         0.065145        0.027374        0.997500        -39.934928   \n",
      "8         0.065145        0.027374        0.997500        -39.934928   \n",
      "9         0.065145        0.027374        0.997500        -39.934928   \n",
      "10        0.067222        0.026625        0.997383        -39.934928   \n",
      "11        0.067222        0.026625        0.997383        -39.934928   \n",
      "12        0.066239        0.023518        0.997527        -39.934928   \n",
      "13        0.066338        0.023840        0.997512        -39.934928   \n",
      "14        0.066338        0.023840        0.997512        -39.934928   \n",
      "15        0.066338        0.023840        0.997512        -39.934928   \n",
      "16        0.064824        0.024375        0.997599        -39.934928   \n",
      "17        0.063962        0.024893        0.997642        -39.934928   \n",
      "18        0.063962        0.024893        0.997642        -39.934928   \n",
      "19        0.063320        0.025199        0.997675        -39.934928   \n",
      "\n",
      "    eye_center1_3d_y  eye_center1_3d_z  gaze_normal1_x  gaze_normal1_y  \\\n",
      "0                NaN               NaN             NaN             NaN   \n",
      "1                NaN               NaN             NaN             NaN   \n",
      "2                NaN               NaN             NaN             NaN   \n",
      "3                NaN               NaN             NaN             NaN   \n",
      "4                NaN               NaN             NaN             NaN   \n",
      "5          14.997919        -20.075283       -0.145087        0.230744   \n",
      "6          14.997919        -20.075283       -0.145087        0.230744   \n",
      "7          14.997919        -20.075283       -0.145087        0.230744   \n",
      "8          14.997919        -20.075283       -0.153085        0.220988   \n",
      "9          14.997919        -20.075283       -0.152523        0.222659   \n",
      "10         14.997919        -20.075283       -0.152523        0.222659   \n",
      "11         14.997919        -20.075283       -0.152228        0.229814   \n",
      "12         14.997919        -20.075283       -0.152228        0.229814   \n",
      "13         14.997919        -20.075283       -0.152228        0.229814   \n",
      "14         14.997919        -20.075283       -0.151781        0.233679   \n",
      "15         14.997919        -20.075283       -0.152094        0.233980   \n",
      "16         14.997919        -20.075283       -0.152094        0.233980   \n",
      "17         14.997919        -20.075283       -0.152094        0.233980   \n",
      "18         14.997919        -20.075283       -0.151527        0.234143   \n",
      "19         14.997919        -20.075283       -0.151527        0.234143   \n",
      "\n",
      "    gaze_normal1_z  \n",
      "0              NaN  \n",
      "1              NaN  \n",
      "2              NaN  \n",
      "3              NaN  \n",
      "4              NaN  \n",
      "5         0.962137  \n",
      "6         0.962137  \n",
      "7         0.962137  \n",
      "8         0.963187  \n",
      "9         0.962891  \n",
      "10        0.962891  \n",
      "11        0.961255  \n",
      "12        0.961255  \n",
      "13        0.961255  \n",
      "14        0.960394  \n",
      "15        0.960271  \n",
      "16        0.960271  \n",
      "17        0.960271  \n",
      "18        0.960321  \n",
      "19        0.960321  \n",
      "\n",
      "[20 rows x 21 columns]\n"
     ]
    }
   ],
   "source": [
    "data = pd.read_csv('gaze.csv')\n",
    "data['gaze_timestamp'] = pd.to_datetime(data['gaze_timestamp'], unit='s')\n",
    "data['gaze_timestamp'] = data['gaze_timestamp'].dt.strftime('%Y-%m-%dT%H:%M:%S.%f+0000')\n",
    "print(data.head(20)) "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3534951c",
   "metadata": {},
   "source": [
    "## (4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "2564ca88",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "采样率: 427.6226938619197 Hz\n"
     ]
    }
   ],
   "source": [
    "data = pd.read_csv('gaze.csv')\n",
    "sampling_rate = 1 / np.diff(data['gaze_timestamp'].values).mean()\n",
    "print(f\"采样率: {sampling_rate} Hz\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a29a91f3",
   "metadata": {},
   "source": [
    "## (5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "cdfc10d8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                         world_index  confidence  norm_pos_x  norm_pos_y  \\\n",
      "gaze_timestamp                                                             \n",
      "1970-01-01 00:01:28.150            0    0.828006    0.531433    0.397509   \n",
      "1970-01-01 00:01:28.160          277    0.804531    0.385470    0.396984   \n",
      "1970-01-01 00:01:28.170          577    0.719673    0.384208    0.402370   \n",
      "1970-01-01 00:01:28.180          877    0.765780    0.410716    0.394018   \n",
      "1970-01-01 00:01:28.190         1177    0.799500    0.381383    0.406377   \n",
      "1970-01-01 00:01:28.200         1477    0.887257    0.387163    0.396682   \n",
      "1970-01-01 00:01:28.210         1777    0.927215    0.334076    0.418351   \n",
      "1970-01-01 00:01:28.220         2077    0.145693    0.686647    0.415226   \n",
      "1970-01-01 00:01:28.230         2377    0.984865    0.414624    0.413123   \n",
      "1970-01-01 00:01:28.240         2677    0.842122    0.392799    0.411926   \n",
      "1970-01-01 00:01:28.250         2977    0.825848    0.279252    0.423024   \n",
      "1970-01-01 00:01:28.260         3277    0.999047    0.325920    0.453338   \n",
      "1970-01-01 00:01:28.270         3577    0.998106    0.387198    0.395510   \n",
      "1970-01-01 00:01:28.280         3877    0.999510    0.413297    0.398612   \n",
      "1970-01-01 00:01:28.290         4177    0.980486    0.366953    0.405037   \n",
      "1970-01-01 00:01:28.300         4477    0.999691    0.489042    0.415115   \n",
      "1970-01-01 00:01:28.310         4777    0.084765    0.471339    0.297810   \n",
      "1970-01-01 00:01:28.320         5077    0.915361    0.377318    0.432846   \n",
      "1970-01-01 00:01:28.330         5377    0.999626    0.372445    0.420249   \n",
      "1970-01-01 00:01:28.340         5677    0.872760    0.347005    0.408975   \n",
      "\n",
      "                                                       base_data  \\\n",
      "gaze_timestamp                                                     \n",
      "1970-01-01 00:01:28.150                            88150.77678-0   \n",
      "1970-01-01 00:01:28.160             88159.999583-0 88160.00739-1   \n",
      "1970-01-01 00:01:28.170            88170.003678-0 88169.999598-1   \n",
      "1970-01-01 00:01:28.180        88179.99943-0 88180.00353799999-1   \n",
      "1970-01-01 00:01:28.190  88189.99957599999-0 88190.00357399999-1   \n",
      "1970-01-01 00:01:28.200       88199.999421-0 88200.00347299999-1   \n",
      "1970-01-01 00:01:28.210        88210.00359499999-0 88209.99955-1   \n",
      "1970-01-01 00:01:28.220                           88220.003493-1   \n",
      "1970-01-01 00:01:28.230       88230.003743-0 88229.99955299999-1   \n",
      "1970-01-01 00:01:28.240       88239.999449-0 88240.00344799999-1   \n",
      "1970-01-01 00:01:28.250            88249.999474-0 88250.003491-1   \n",
      "1970-01-01 00:01:28.260  88260.00112199999-0 88260.00106899999-1   \n",
      "1970-01-01 00:01:28.270  88270.00361999999-0 88269.99959899999-1   \n",
      "1970-01-01 00:01:28.280       88279.99947499999-0 88280.005076-1   \n",
      "1970-01-01 00:01:28.290  88290.00409999999-0 88289.99951699999-1   \n",
      "1970-01-01 00:01:28.300       88300.00354199999-0 88299.999444-1   \n",
      "1970-01-01 00:01:28.310                      88310.00355099999-1   \n",
      "1970-01-01 00:01:28.320            88319.999486-0 88320.003482-1   \n",
      "1970-01-01 00:01:28.330            88330.003541-0 88329.999468-1   \n",
      "1970-01-01 00:01:28.340       88340.003514-0 88339.99949799999-1   \n",
      "\n",
      "                         gaze_point_3d_x  gaze_point_3d_y  gaze_point_3d_z  \\\n",
      "gaze_timestamp                                                               \n",
      "1970-01-01 00:01:28.150        28.369753        52.033135       705.121116   \n",
      "1970-01-01 00:01:28.160      1937.881053      -980.473996    -13219.030499   \n",
      "1970-01-01 00:01:28.170      -383.979920       182.111861      2590.726230   \n",
      "1970-01-01 00:01:28.180       291.967760      -194.946093     -2554.769540   \n",
      "1970-01-01 00:01:28.190     -3362.080783      1492.671013     22143.743436   \n",
      "1970-01-01 00:01:28.200      1690.006637      -870.432811    -11701.092069   \n",
      "1970-01-01 00:01:28.210       -91.581380        25.349602       431.209754   \n",
      "1970-01-01 00:01:28.220       362.124804        92.517537      1515.748344   \n",
      "1970-01-01 00:01:28.230       154.686945       -88.540923     -1415.486599   \n",
      "1970-01-01 00:01:28.240       -96.064381        44.394968       700.088406   \n",
      "1970-01-01 00:01:28.250       -71.809438        14.085273       254.140952   \n",
      "1970-01-01 00:01:28.260       -34.960650         5.271221       156.898907   \n",
      "1970-01-01 00:01:28.270       267.461654      -139.360765     -1852.394856   \n",
      "1970-01-01 00:01:28.280       246.997804      -162.468200     -2225.600346   \n",
      "1970-01-01 00:01:28.290    -13383.188696      5373.173071     78585.632934   \n",
      "1970-01-01 00:01:28.300        27.577860      -120.171843     -1966.246461   \n",
      "1970-01-01 00:01:28.310     -1377.254920      5465.247435     37541.992401   \n",
      "1970-01-01 00:01:28.320       -80.541403        24.798841       512.893356   \n",
      "1970-01-01 00:01:28.330      -200.758775        70.604853      1229.607060   \n",
      "1970-01-01 00:01:28.340      -144.393433        48.322945       737.328699   \n",
      "\n",
      "                         eye_center0_3d_x  eye_center0_3d_y  eye_center0_3d_z  \\\n",
      "gaze_timestamp                                                                  \n",
      "1970-01-01 00:01:28.150         20.000000         15.000000        -20.000000   \n",
      "1970-01-01 00:01:28.160         19.992440         14.965000        -20.046054   \n",
      "1970-01-01 00:01:28.170         19.980161         14.901910        -20.132636   \n",
      "1970-01-01 00:01:28.180         19.974507         14.911168        -20.109725   \n",
      "1970-01-01 00:01:28.190         19.974507         14.911168        -20.109725   \n",
      "1970-01-01 00:01:28.200         19.918757         14.571796        -20.585329   \n",
      "1970-01-01 00:01:28.210         19.879866         14.373939        -20.866008   \n",
      "1970-01-01 00:01:28.220        -37.156835         14.774701        -23.378570   \n",
      "1970-01-01 00:01:28.230         19.879866         14.373939        -20.866008   \n",
      "1970-01-01 00:01:28.240         19.890141         14.473594        -20.712888   \n",
      "1970-01-01 00:01:28.250         19.892015         14.485896        -20.712604   \n",
      "1970-01-01 00:01:28.260         19.895395         14.512441        -20.685515   \n",
      "1970-01-01 00:01:28.270         19.898248         14.496833        -20.716116   \n",
      "1970-01-01 00:01:28.280         19.898248         14.496833        -20.716116   \n",
      "1970-01-01 00:01:28.290         19.898248         14.496833        -20.716116   \n",
      "1970-01-01 00:01:28.300         19.898248         14.496833        -20.716116   \n",
      "1970-01-01 00:01:28.310        -37.168463         14.778240        -23.531224   \n",
      "1970-01-01 00:01:28.320         19.898248         14.496833        -20.716116   \n",
      "1970-01-01 00:01:28.330         19.898248         14.496833        -20.716116   \n",
      "1970-01-01 00:01:28.340         19.898248         14.496833        -20.716116   \n",
      "\n",
      "                         gaze_normal0_x  gaze_normal0_y  gaze_normal0_z  \\\n",
      "gaze_timestamp                                                            \n",
      "1970-01-01 00:01:28.150        0.011527        0.051002        0.998632   \n",
      "1970-01-01 00:01:28.160       -0.143049        0.044802        0.988701   \n",
      "1970-01-01 00:01:28.170       -0.152644        0.049510        0.987040   \n",
      "1970-01-01 00:01:28.180       -0.106337        0.028635        0.993918   \n",
      "1970-01-01 00:01:28.190       -0.150531        0.054568        0.987098   \n",
      "1970-01-01 00:01:28.200       -0.141242        0.061455        0.988066   \n",
      "1970-01-01 00:01:28.210       -0.238432        0.082267        0.967669   \n",
      "1970-01-01 00:01:28.220        0.250809        0.048834        0.966804   \n",
      "1970-01-01 00:01:28.230       -0.096196        0.046818        0.994261   \n",
      "1970-01-01 00:01:28.240       -0.158836        0.006960        0.987280   \n",
      "1970-01-01 00:01:28.250       -0.313384        0.124758        0.941396   \n",
      "1970-01-01 00:01:28.260       -0.294629       -0.024977        0.955285   \n",
      "1970-01-01 00:01:28.270       -0.133260        0.103593        0.985652   \n",
      "1970-01-01 00:01:28.280       -0.102380        0.044763        0.993738   \n",
      "1970-01-01 00:01:28.290       -0.167206        0.109286        0.979846   \n",
      "1970-01-01 00:01:28.300       -0.005248       -0.095295        0.995435   \n",
      "1970-01-01 00:01:28.310       -0.035282        0.143499        0.989021   \n",
      "1970-01-01 00:01:28.320       -0.184920        0.023098        0.982482   \n",
      "1970-01-01 00:01:28.330       -0.173408        0.067820        0.982512   \n",
      "1970-01-01 00:01:28.340       -0.210899        0.098697        0.972512   \n",
      "\n",
      "                         eye_center1_3d_x  eye_center1_3d_y  eye_center1_3d_z  \\\n",
      "gaze_timestamp                                                                  \n",
      "1970-01-01 00:01:28.150        -39.934928         14.997919        -20.075283   \n",
      "1970-01-01 00:01:28.160        -38.852672         14.355544        -20.619832   \n",
      "1970-01-01 00:01:28.170        -34.185239         14.649610        -27.883289   \n",
      "1970-01-01 00:01:28.180        -36.825200         14.754603        -23.963386   \n",
      "1970-01-01 00:01:28.190        -37.149450         14.796510        -23.363112   \n",
      "1970-01-01 00:01:28.200        -36.849857         14.797774        -23.811000   \n",
      "1970-01-01 00:01:28.210        -37.081142         14.775521        -23.466993   \n",
      "1970-01-01 00:01:28.220        -37.156835         14.774701        -23.378570   \n",
      "1970-01-01 00:01:28.230        -37.093785         14.775235        -23.486804   \n",
      "1970-01-01 00:01:28.240        -37.314452         14.767433        -23.183648   \n",
      "1970-01-01 00:01:28.250        -37.718490         14.754561        -22.601715   \n",
      "1970-01-01 00:01:28.260        -37.619749         14.756739        -22.777846   \n",
      "1970-01-01 00:01:28.270        -37.168200         14.782509        -23.543019   \n",
      "1970-01-01 00:01:28.280        -37.168200         14.782509        -23.543019   \n",
      "1970-01-01 00:01:28.290        -37.168463         14.778240        -23.531224   \n",
      "1970-01-01 00:01:28.300        -37.168463         14.778240        -23.531224   \n",
      "1970-01-01 00:01:28.310        -37.168463         14.778240        -23.531224   \n",
      "1970-01-01 00:01:28.320        -37.168463         14.778240        -23.531224   \n",
      "1970-01-01 00:01:28.330        -37.168463         14.778240        -23.531224   \n",
      "1970-01-01 00:01:28.340        -37.168463         14.778240        -23.531224   \n",
      "\n",
      "                         gaze_normal1_x  gaze_normal1_y  gaze_normal1_z  \n",
      "gaze_timestamp                                                           \n",
      "1970-01-01 00:01:28.150       -0.145087        0.230744        0.962137  \n",
      "1970-01-01 00:01:28.160       -0.147928        0.103897        0.983526  \n",
      "1970-01-01 00:01:28.170       -0.132067        0.076904        0.988253  \n",
      "1970-01-01 00:01:28.180       -0.128066        0.135069        0.982525  \n",
      "1970-01-01 00:01:28.190       -0.147984        0.076982        0.985989  \n",
      "1970-01-01 00:01:28.200       -0.145759        0.088109        0.985389  \n",
      "1970-01-01 00:01:28.210       -0.119251       -0.035696        0.992222  \n",
      "1970-01-01 00:01:28.220       -0.113728        0.092547        0.989192  \n",
      "1970-01-01 00:01:28.230       -0.135795        0.099714        0.985706  \n",
      "1970-01-01 00:01:28.240       -0.080613        0.074737        0.993940  \n",
      "1970-01-01 00:01:28.250       -0.121861       -0.128511        0.984192  \n",
      "1970-01-01 00:01:28.260        0.014715       -0.077364        0.996894  \n",
      "1970-01-01 00:01:28.270       -0.163893        0.062179        0.984517  \n",
      "1970-01-01 00:01:28.280       -0.127190        0.114303        0.985270  \n",
      "1970-01-01 00:01:28.290       -0.167203        0.024696        0.985613  \n",
      "1970-01-01 00:01:28.300       -0.031417        0.231740        0.972270  \n",
      "1970-01-01 00:01:28.310       -0.092897        0.105087        0.990115  \n",
      "1970-01-01 00:01:28.320       -0.080602        0.014487        0.996641  \n",
      "1970-01-01 00:01:28.330       -0.129451        0.020436        0.991375  \n",
      "1970-01-01 00:01:28.340       -0.139591       -0.011646        0.990141  \n"
     ]
    }
   ],
   "source": [
    "data = pd.read_csv('gaze.csv')\n",
    "data['gaze_timestamp'] = pd.to_datetime(data['gaze_timestamp'], unit='ms')\n",
    "data.set_index('gaze_timestamp', inplace=True)\n",
    "data = data.resample('10ms').first().interpolate()\n",
    "print(data.head(20)) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ae3a0bf9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
